package com.itheima.个人代码.IO流2;

import java.io.*;

public class Demo10 {
    public static void main(String[] args) throws IOException {
        //bufferedwriter();
        //bufferedwriter1();
        //bufferedwriter2();
        //bufferedwriter3();


    }

    public static void bufferedwriter3() throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("IO流2和对象操作流properties\\stu.txt"));
        String str = null;
        while ((str = br.readLine()) != null) {
            System.out.println(str);
        }
    }

    public static void bufferedwriter2() throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter("IO流2和对象操作流properties\\stu.txt", true));
        bw.write("谁知盘中餐");
        bw.newLine();
        bw.write("粒粒皆辛苦");
        bw.newLine();
        bw.flush();
        bw.close();
    }

    public static void bufferedwriter1() throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter("IO流2和对象操作流properties\\stu.txt", true));
        bw.write("   悯农   ");
        bw.newLine();
        bw.write("锄禾日当午");
        bw.newLine();
        bw.write("汗滴禾下土");
        bw.newLine();
        bw.write("谁知盘中餐");
        bw.newLine();
        bw.write("粒粒皆辛苦");
        bw.newLine();
        bw.flush();
        bw.close();
    }

    public static void bufferedwriter() throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter("IO流2和对象操作流properties\\stu.txt"));
        bw.write("您好啊,好久不见,怎么样啊=====================", 0, 22);
        bw.newLine();
        bw.close();
    }
}
